package com.heking.aoplib;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

import com.zhoug.common.router.ZRouter;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * @Author 35574
 * @Date 2020/7/1
 * @Description
 */
public class LoginActivity extends AppCompatActivity {

    private Button mBtn1;
    private Button mBtn2;
    public static final String EXTRA_FOR_RESULT="forResult";
    public static final String OUT_PUT_LOGIN_SUCCESS="loginSuccess";
    private boolean forResult=false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Bundle extras = getIntent().getExtras();
        if(extras!=null){
            forResult=extras.getBoolean(EXTRA_FOR_RESULT,false);
        }
        findViews();

        mBtn1.setOnClickListener(v->{
            if(forResult){
                Intent intent=new Intent();
                intent.putExtra(OUT_PUT_LOGIN_SUCCESS,true);
                setResult(RESULT_OK,intent);
                finish();
            }else{
                ZRouter.navigation(this,HomeActivity.class);
            }
        });
        mBtn2.setOnClickListener(v->{
            Toast.makeText(getApplication(), "登录失败", Toast.LENGTH_SHORT).show();
        });
    }

    private void findViews() {
        mBtn1 = findViewById(R.id.btn1);
        mBtn2 = findViewById(R.id.btn2);
    }
}

